﻿<%@ Control Language="VB" AutoEventWireup="false" CodeFile="Uc_type_list.ascx.vb"
    Inherits="Apps_Shares_Uc_type_list" %>
<%--==============================BEGIN Filter==============================--%>
<table width="50%" border="1" align="center" cellpadding="2" cellspacing="2" bordercolor="#999999">
    <tr align="center" bgcolor="#99FFFF">
        <td colspan="2" bgcolor="#FFFFFF" class="th_data">
            ค้นหาข้อมูล
        </td>
    </tr>
    <tr align="left">
        <td width="47%" bordercolor="#CCCCCC" class="td_box">
            ชื่อประเภทการจัดการข้อมูล :
        </td>
        <td width="53%" bordercolor="#CCCCCC" class="td_box">
            <asp:TextBox ID='txtTypeName' runat='server'></asp:TextBox>
        </td>
    </tr>
    <tr align="left">
        <td width="47%" bordercolor="#CCCCCC" class="td_box">
            สถานะ :
        </td>
        <td width="53%" bordercolor="#CCCCCC" class="td_box">
            <asp:DropDownList ID='ddlStatus' runat="server">
                <asp:ListItem Text='สถานะ' Value='0'></asp:ListItem>
                <asp:ListItem Text='ใช้งาน' Value='1'></asp:ListItem>
                <asp:ListItem Text='ไม่ใช้งาน' Value='2'></asp:ListItem>
            </asp:DropDownList>
        </td>
    </tr>
    <tr align="center">
        <td colspan="2" bordercolor="#CCCCCC" class="td_data_end">
            <asp:Button ID='btnFilter' Text='<%$ Resources:Resource,BTN_SEARCH %>' runat='server' />
            <asp:Button ID='btnMainMenu' Text='<%$ Resources:Resource,BTN_MAINMENU %>' runat='server' PostBackUrl="~/Apps/ViewSystem.aspx?Edit=2" />
        </td>
    </tr>
</table>
<%--==============================END Filter==============================--%>
<div style="margin:5px;display:block;width:100%">&nbsp;</div>
<%--==============================BEGIN Gridview==============================--%>
<span class='component_caption'>
    <asp:Literal ID='ltrCountView' runat='server' Text=''></asp:Literal></span>
<asp:ListView ID="gvDisplay" runat="server" DataSourceID="srcList" DataKeyNames='type_code'
    EnableModelValidation="True">
    <LayoutTemplate>
        <table cellspacing="2" cellpadding="2" bordercolor="#999999" border="0" align="center"
            width="100%">
            <tbody>
                <tr bgcolor="#ff9999" align="center" >
                    <td bgcolor="#ffffff" class="th_data">
                        <asp:Image ID="type_name" runat="server" Visible="false" />
                        <asp:LinkButton ID='sort2' runat='server' CommandName='Sort' CommandArgument='type_name'>
                                ชื่อประเภทการจัดการข้อมูล
                        </asp:LinkButton>
                    </td>
                    <td bgcolor="#ffffff" class="th_data">
                        <asp:Image ID="status" runat="server" Visible="false" />
                        <asp:LinkButton ID='sort3' runat='server' CommandName='Sort' CommandArgument='status'>
                                สถานะ
                        </asp:LinkButton>
                    </td>
                    <td bgcolor="#ffffff" class="th_data col_delete">
                        <input id='icbHeader' type='checkbox' />
                        ลบข้อมูล
                    </td>
                </tr>
                <asp:PlaceHolder ID='itemPlaceholder' runat='server' />
                <tr bgcolor="#ff9999" align="center">
                    <td bgcolor="#ffffff" class="td_data_end" colspan="2">
                        <%-- ====================== Data Pager ======================--%>
                        <asp:DataPager ID="paging" runat="server" PagedControlID="gvDisplay" PageSize='10'>
                            <Fields>
                                <asp:NextPreviousPagerField ShowFirstPageButton="true" ShowLastPageButton="false"
                                    ShowNextPageButton='false' ShowPreviousPageButton='false' FirstPageText='<<' />
                                <asp:NextPreviousPagerField ShowFirstPageButton="false" ShowLastPageButton="false"
                                    ShowNextPageButton='false' ShowPreviousPageButton='true' PreviousPageText='<' />
                                <asp:NumericPagerField />
                                <asp:NextPreviousPagerField ShowFirstPageButton="false" ShowLastPageButton="false"
                                    ShowNextPageButton='true' ShowPreviousPageButton='false' NextPageText='>' />
                                <asp:NextPreviousPagerField ShowFirstPageButton="false" ShowLastPageButton="true"
                                    ShowNextPageButton='false' ShowPreviousPageButton='false' LastPageText='>>' />
                            </Fields>
                        </asp:DataPager>
                        <%-- ====================== Data Pager ======================--%>
                    </td>
                    <td bgcolor="#ffffff" class="td_data_end col_delete">
                        <asp:Button ID='btnDelete' runat='server' Text='ลบข้อมูล' OnClick='btnDelete_Click'
                            OnClientClick='<%$Resources:Resource,SCRIPT_CONFIRM_DELETE %>' />
                    </td>
                </tr>
            </tbody>
        </table>
    </LayoutTemplate>
    <EmptyDataTemplate>
        <br />
        <span class='star'>
            <center>
                ไม่พบข้อมูล</center>
        </span>
    </EmptyDataTemplate>
    <ItemTemplate>
        <tr>
            <td align="left" class="td_data" bordercolor="#CCCCCC">
                <a href='<%# "type_fv.aspx?Edit=" & Eval("type_code") & CodeMatrix.Business.GenericData.GetViewMode() %>'>
                    <%# Eval("type_name")%>
                </a>
            </td>
            <td align="center" class="td_data f_status" bordercolor="#CCCCCC">
                <%# Eval("status")%>
            </td>
            <td align="center" class="td_data col_delete" bordercolor="#CCCCCC">
                <asp:CheckBox ID='icbItem' runat='server' />
            </td>
        </tr>
    </ItemTemplate>
</asp:ListView>
<asp:SqlDataSource ID="srcList" runat="server" ConnectionString="<%$ ConnectionStrings:ApplicationServices %>"
    SelectCommand="
        select	type_code ,
		        [type_name] ,
		        status = case type_status
			        when 1 then 'ใชังาน'
			        when 2 then 'ไม่ใช้งาน'
		        end , SeqNo = ROW_NUMBER() over(order by type_code)
        from	master_type
        where	@type_status in (0,type_status) and 
		        [type_name] like '%' + @type_name + '%'" DeleteCommand="EXEC  [dbo].[USP_GenericDelete] @tbl,@pid,@cid">
    <DeleteParameters>
        <asp:Parameter DefaultValue="master_type" Name="tbl" Type="String" />
        <asp:Parameter DefaultValue="type_code" Name="pid" Type="String" />
        <asp:Parameter DefaultValue="" Name="cid" Type="String" />
    </DeleteParameters>
    <SelectParameters>
        <asp:ControlParameter ControlID="ddlStatus" Name="type_status" PropertyName="SelectedValue" />
        <asp:ControlParameter ControlID="txtTypeName" ConvertEmptyStringToNull="False" Name="type_name"
            PropertyName="Text" />
    </SelectParameters>
</asp:SqlDataSource>
<%--==============================END Gridview==============================--%>

<script type="text/javascript">
    matchTableCheckBox('icbHeader', 'icbItem');
    hideDeleteColumn();
    hilightInactive();
</script>

